home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-06-28 | 61.6 KB | 2,910 lines |
- Path: xanth!cs.odu.edu!Amiga-Request
- From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
- Newsgroups: comp.sources.amiga
- Subject: v90i182: UUCP 1.06D - UNIX compatible uucp/news/mail system, Part04/12
- Message-ID: <12973@xanth.cs.odu.edu>
- Date: 28 Jun 90 12:22:31 GMT
- Sender: news@cs.odu.edu
- Reply-To: Matt Dillon <@uunet.uu.net:overload!dillon>
- Lines: 2896
- Approved: tadguy@cs.odu.edu (Tad Guy)
- X-Mail-Submissions-To: Amiga@cs.odu.edu
- X-Post-Discussions-To: comp.sys.amiga
-
- Submitted-by: Matt Dillon <@uunet.uu.net:overload!dillon>
- Posting-number: Volume 90, Issue 182
- Archive-name: unix/uucp-1.06d/part04
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 4 (of 12)."
- # Contents: uucp2/src/GUtil/gnote.c uucp2/src/GUtil/uuserdump.c
- # uucp2/src/anews/followup.c uucp2/src/anews/reply.c
- # uucp2/src/dmail/do_lists.c uucp2/src/dmail/range.c
- # uucp2/src/lib/config.c uucp2/src/lib/list_sort.c
- # uucp2/src/news/postnews.c uucp2/src/unix/tarsplit.c
- # uucp2/src/unix/uudecode.c uucp2/src/uucico/modem.c
- # uucp2/src/uucico/uucp.c uucp2/src/uucico/uux.c
- # Wrapped by tadguy@xanth on Thu Jun 28 08:21:21 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'uucp2/src/GUtil/gnote.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/GUtil/gnote.c'\"
- else
- echo shar: Extracting \"'uucp2/src/GUtil/gnote.c'\" \(3473 characters\)
- sed "s/^X//" >'uucp2/src/GUtil/gnote.c' <<'END_OF_FILE'
- X
- X/*
- X * GNOTE.C
- X *
- X * $Header: Beta:src/uucp/src/GUtil/RCS/gnote.c,v 1.1 90/02/02 11:58:55 dillon Exp Locker: dillon $
- X *
- X * (C) Copyright 1989-1990 by Matthew Dillon, All Rights Reserved.
- X *
- X * GNOTE hellofile notefile
- X *
- X * Allow the user to enter a note and append it to notefile. See
- X * Getty. Password entry should have a '*' in front of the executable
- X * name for Getty to provide automatic stdin/stdout
- X *
- X */
- X
- X#include <stdio.h>
- X#include <time.h>
- X#include "protos.h"
- X#include "version.h"
- X
- XIDENT(".01");
- X
- Xchar *GetLine();
- Xvoid PutDaChar();
- Xvoid FlushChars();
- X
- Xmain(ac, av)
- Xchar *av[];
- X{
- X time_t t;
- X char *ptr;
- X FILE *fi;
- X
- X time(&t);
- X
- X if (ac < 3) {
- X printf("gnote: expect 2 arguments, got %d\n", ac - 1);
- X fflush(stdout);
- X Delay(50*2);
- X exit(1);
- X }
- X printf("%s %s", Ident, ctime(&t));
- X if (fi = fopen(av[1], "r")) {
- X char buf[128];
- X while (fgets(buf, sizeof(buf), fi)) {
- X short len = strlen(buf);
- X if (len > 0 && buf[len-1] == '\n')
- X --len;
- X buf[len++] = 13;
- X buf[len++] = 10;
- X buf[len++] = 0;
- X fputs(buf, stdout);
- X }
- X fclose(fi);
- X }
- X fflush(stdout);
- X
- X if ((fi = fopen(av[2], "a")) == NULL) {
- X puts("couldn't open note file");
- X fflush(stdout);
- X Delay(50*2);
- X exit(1);
- X }
- X fprintf(fi, "**NOTE** %s", ctime(&t));
- X
- X while (ptr = GetLine()) {
- X if (strcmp(ptr, ".") == 0)
- X break;
- X if (strncmp(ptr, "**NOTE**", 8) == 0)
- X fprintf(fi, " ");
- X fprintf(fi, "%s\n", ptr);
- X }
- X puts("Thank you, hanging up in 8 seconds");
- X fflush(stdout);
- X fclose(fi);
- X Delay(50*8);
- X return(0);
- X}
- X
- X
- Xchar *
- XGetLine()
- X{
- X static char buf[256];
- X static char tab[256];
- X short col = 0;
- X short i = 0;
- X short limit = 5*60; /* 5 minute idle timeout */
- X short lcnt = 0;
- X short c;
- X
- X for (;;) {
- X c = GetDaChar();
- X if (c == EOF) {
- X clearerr(stdin);
- X ++lcnt;
- X if (lcnt == limit - 30) {
- X puts("\r\n(idle, hangup in 30)\r\n");
- X fflush(stdout);
- X }
- X if (lcnt == limit)
- X break;
- X continue;
- X }
- X lcnt = 0;
- X
- X switch(c) {
- X case 10:
- X case 13:
- X PutDaChar('\r');
- X PutDaChar('\n');
- X FlushChars();
- X buf[i] = 0;
- X return(buf);
- X case 8:
- X case 127:
- X if (i) {
- X short n = 1;
- X --i;
- X if (buf[i] == 9)
- X n = tab[i];
- X col -= n;
- X while (n--) {
- X PutDaChar('\010');
- X PutDaChar(' ');
- X PutDaChar('\010');
- X }
- X }
- X break;
- X case 'x'&0x1F:
- X PutDaChar('^');
- X PutDaChar('X');
- X PutDaChar('\r');
- X PutDaChar('\n');
- X i = 0;
- X break;
- X case 'r'&0x1F:
- X PutDaChar('\r');
- X PutDaChar('\n');
- X FlushChars();
- X buf[i] = 0;
- X printf("%s", buf);
- X fflush(stdout);
- X break;
- X case 9:
- X if (i < sizeof(buf) - 2) {
- X tab[i] = 8 - (col & 7);
- X col += tab[i] - 1; /* because we ++ below */
- X }
- X /* fall through */
- X default:
- X if (i < sizeof(buf) - 2) {
- X PutDaChar(c);
- X buf[i++] = c;
- X ++col;
- X } else {
- X PutDaChar('g' & 0x1F);
- X }
- X break;
- X }
- X }
- X return(NULL);
- X}
- X
- Xvoid
- XFlushChars()
- X{
- X PutDaChar(256);
- X}
- X
- Xvoid
- XPutDaChar(c)
- X{
- X static char buf[256];
- X static short len;
- X
- X if (c == 256 || len == sizeof(buf)) {
- X if (len)
- X write(1, buf, len);
- X len = 0;
- X }
- X if (c != 256)
- X buf[len++] = c;
- X}
- X
- X
- XGetDaChar()
- X{
- X static char buf[256];
- X static short idx, len;
- X
- X if (idx == len) {
- X if (read(0, buf, 0) < 0)
- X FlushChars();
- X idx = 0;
- X len = read(0, buf, sizeof(buf));
- X if (len <= 0) {
- X len = 0;
- X return(EOF);
- X }
- X }
- X return((int)buf[idx++]);
- X}
- X
- END_OF_FILE
- if test 3473 -ne `wc -c <'uucp2/src/GUtil/gnote.c'`; then
- echo shar: \"'uucp2/src/GUtil/gnote.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/GUtil/gnote.c'
- fi
- if test -f 'uucp2/src/GUtil/uuserdump.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/GUtil/uuserdump.c'\"
- else
- echo shar: Extracting \"'uucp2/src/GUtil/uuserdump.c'\" \(4092 characters\)
- sed "s/^X//" >'uucp2/src/GUtil/uuserdump.c' <<'END_OF_FILE'
- X
- X/*
- X * UUSERDUMP.C
- X *
- X * $Header: Beta:src/uucp/src/GUtil/RCS/uuserdump.c,v 1.1 90/02/02 11:58:57 dillon Exp Locker: dillon $
- X *
- X * (C) Copyright 1989-1990 by Matthew Dillon, All Rights Reserved.
- X *
- X * UUSERDUMP filename
- X *
- X * KEY THINGS ABOUT UUSER: USED AS STDIN/STDOUT
- X *
- X * Currently UUSER: works only with single sessions started
- X * by Getty (this has to do with how UUSER: deals with carrier
- X * detect). THIS WILL BE FIXED.
- X *
- X * (1) Use Level 1 I/O if you can (read/write)
- X * read() returns 0 on timeout, -1 on carrier lost
- X * otherwise, read() returns the immediate number of
- X * data bytes ready up to the amount you requested.
- X * (i.e. if you read(0,buf,256) you can get anywhere from
- X * -1, 0, 1 to 256 back).
- X *
- X * write() returns the number you wrote or -1 (lost carrier)
- X *
- X * To 'poll' data ready you can read(0, NULL, 0) .. reading
- X * 0 bytes returns 0 (data ready) or -1 (data not ready).
- X * NOTE: 0 (data ready) will be returned if carrier is lost
- X * when you read 0 bytes... this is so your program thinks
- X * data is ready and when it does a real read it finds that
- X * carrier was lost!
- X *
- X * (2) If you want to use Level 2 I/O (stdio) I suggest you use
- X * it for writing only. If you really want to use it for
- X * reading remember that the timeout will cause an EOF
- X * condition which must be cleared (clrerr()). And you
- X * must call ferror() to determine whether an EOF is an
- X * EOF (timeout()) or an actual error (lost carrier).
- X */
- X
- X#include <stdio.h>
- X#include "protos.h"
- X#include "version.h"
- X
- XIDENT(".01");
- X
- Xchar buf[256];
- Xshort i;
- X
- Xint
- Xbrk()
- X{
- X return(0);
- X}
- X
- Xmain(ac, av)
- Xchar *av[];
- X{
- X short i;
- X char c;
- X short n;
- X FILE *fi = fopen(av[1], "r");
- X
- X onbreak(brk);
- X /*
- X * set output to line buffering (stdio), else it will use
- X * file buffering! Which is bad if we want to catch ^S/^C
- X */
- X
- X setvbuf(stdout, NULL, _IOLBF, 0);
- X
- X
- X if (ac == 1)
- X exit(1);
- X
- X if (fi == NULL)
- X printf("Info file %s not available\r\n", av[1]);
- X
- X printf("Dumping info file (suggest capture), hit Enter when ready\n");
- X fflush(stdout);
- X
- X /*
- X * Getty uses the R1000 option, so there is a one second timeout
- X * on reads when no data is present. If data is present, UUSER:
- X * returns the number of bytes immediately available regardless of
- X * how many you requested.
- X */
- X
- X for (i = 0; i < 60; ++i) {
- X n = read(0, &c, 1);
- X if (n < 0) /* lost carrier */
- X exit(1);
- X /* success */
- X if (n > 0 && (c == 10 || c == 13))
- X goto skip;
- X /* timeout */
- X }
- X exit(1);
- Xskip:
- X while (fgets(buf, 256, fi)) {
- X short len = strlen(buf);
- X if (CheckControl())
- X break;
- X if (len > 0 && buf[len-1] == '\n')
- X --len;
- X buf[len++] = 13;
- X buf[len++] = 10;
- X buf[len++] = 0;
- X fputs(buf, stdout);
- X }
- X fclose(fi);
- X
- X printf("End of dump, any key to disconnect\n");
- X fflush(stdout);
- X for (i = 0; i < 60; ++i) {
- X n = read(0, &c, 1);
- X if (n == 0) /* 1 second timeout */
- X continue;
- X break; /* any key or lost cd */
- X }
- X return(0);
- X}
- X
- X/*
- X * Here we use a UUSER: trick ... requesting 0 bytes in a read()
- X * incurs NO timeout. 0 is returned if data is ready, -1 if data
- X * is not ready.
- X *
- X * Another way to do it is to dump a seconds worth of data, then
- X * call read() (which blocks for up to 1 second if no data is
- X * ready, but the user doesn't see that because we've already queued
- X * a second's worth of data). The first method is better because
- X * there is finer granularity (that is, the one used below)
- X */
- X
- XCheckControl()
- X{
- X char c = 0;
- X short n;
- X
- X if (read(0, NULL, 0) == 0) { /* returns 0=data ready, -1=not rdy */
- X read(0, &c, 1);
- X if (c == ('s'&0x1F)) { /* ^S */
- X for (;;) {
- X n = read(0, &c, 1);
- X if (n < 0) /* lost carrier */
- X exit(1);
- X if (n == 0) /* timeout */
- X continue;
- X break; /* got a key */
- X }
- X return(0);
- X }
- X if (c == ('c'&0x1F)) /* ^C */
- X return(1);
- X }
- X return(0);
- X}
- X
- END_OF_FILE
- if test 4092 -ne `wc -c <'uucp2/src/GUtil/uuserdump.c'`; then
- echo shar: \"'uucp2/src/GUtil/uuserdump.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/GUtil/uuserdump.c'
- fi
- if test -f 'uucp2/src/anews/followup.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/anews/followup.c'\"
- else
- echo shar: Extracting \"'uucp2/src/anews/followup.c'\" \(4278 characters\)
- sed "s/^X//" >'uucp2/src/anews/followup.c' <<'END_OF_FILE'
- X
- X/*
- X * FOLLOWUP.C
- X */
- X
- X#include "news.h"
- X#include <time.h>
- X
- Xstatic char Buf[256];
- X
- Xchar *findheader();
- X
- Xstatic char *TempFileName = "T:anews.post.tmp";
- X
- X/*
- X * NOTE: fp can be NULL
- X */
- X
- Xvoid
- Xfollowup(cmd, fp, group)
- Xint cmd;
- XFILE *fp;
- Xconst char *group;
- X{
- X FILE *fo = fopen(TempFileName, "w");
- X char *ptr;
- X char *nodename = FindConfig(NODENAME);
- X char *system_name = FindConfig(NEWSFEED);
- X char *user = FindConfig(USERNAME);
- X char *domain = FindConfig(DOMAINNAME);
- X char *realname = FindConfig(REALNAME);
- X int yes = 0;
- X time_t t = time(NULL);
- X int seq = GetSequence(0);
- X static char *envuser;
- X static char *envrealname;
- X
- X if (fo == NULL) {
- X printf("can't create %s\n", TempFileName);
- X return;
- X }
- X
- X if (nodename == NULL || system_name == NULL || user == NULL || realname == NULL) {
- X printf("Incomplete Configuration, one of:\n");
- X printf("\t%s %s %s %s\n", NODENAME, NEWSFEED, USERNAME, REALNAME);
- X fclose(fo);
- X return;
- X }
- X if (domain == NULL)
- X domain = ".UUCP";
- X
- X /*
- X * Enviroment variable overides
- X */
- X
- X if (envuser == NULL)
- X envuser = MallocEnviro("USER");
- X if (envrealname == NULL)
- X envrealname = MallocEnviro("REALNAME");
- X if (envuser)
- X user = envuser;
- X if (envrealname)
- X realname = envrealname;
- X
- X /*
- X * Create news file
- X */
- X
- X fprintf(fo, "Path: %s!%s\n", nodename, user);
- X fprintf(fo, "From: %s@%s%s (%s)\n", user, nodename, domain, realname);
- X fprintf(fo, "Newsgroups: %s\n", group);
- X
- X fprintf(fo, "Subject: ");
- X if (fp)
- X fprintf(fo, "Re: ");
- X if (ptr = findheader(fp, "Subject:")) {
- X if (strncmpi(ptr, "re:", 3) == 0)
- X ptr += 3;
- X while (*ptr == ' ' || *ptr == 9)
- X ++ptr;
- X fprintf(fo, "%s", ptr);
- X free(ptr);
- X }
- X fputs("\n", fo);
- X
- X fprintf(fo, "Message-Id: <%04d.AA%04d@%s%s>\n", seq, seq, nodename, domain);
- X fprintf(fo, "Date: %s", ctime(&t));
- X fprintf(fo, "Followup-To: %s\n", group);
- X fprintf(fo, "Expires: \n");
- X fprintf(fo, "Keywords: \n");
- X
- X fprintf(fo, "Distribution: ");
- X if (ptr = findheader(fp, "Distribution:")) {
- X fprintf(fo, "%s", ptr);
- X free(ptr);
- X } else {
- X fputs("world", fo);
- X }
- X fputs("\n", fo);
- X
- X /*
- X * upper case, include text
- X */
- X
- X fputs("\n", fo);
- X
- X if (fp && cmd >= 'A' && cmd <= 'Z') {
- X rewind(fp);
- X while (fgets(Buf, sizeof(Buf), fp) && Buf[0] != '\n');
- X while (fgets(Buf, sizeof(Buf), fp)) {
- X fprintf(fo, ">");
- X fputs(Buf, fo);
- X }
- X }
- X fputs("\n", fo);
- X
- X /*
- X * append signature
- X */
- X
- X {
- X FILE *fi;
- X
- X sprintf(Buf, "%s.signature", user);
- X fi = openlib(Buf);
- X if (fi == NULL)
- X fi = openlib(".signature");
- X
- X if (fi) {
- X fputs("--\n", fo);
- X while (fgets(Buf, sizeof(Buf), fi))
- X fputs(Buf, fo);
- X fclose(fi);
- X } else {
- X puts("Warning, no .signature file!");
- X }
- X }
- X
- X fclose(fo);
- X
- X /*
- X * Edit the file
- X */
- X
- X sprintf(Buf, "%s %s", GetConfig(NEWSEDITOR, GetConfig(EDITOR, "dme")), TempFileName);
- X system(Buf);
- X
- X /*
- X * want to post this?
- X */
- X
- X cooked(stdin);
- X printf("Do you want to post this? 'y' or 'n' :");
- X fflush(stdout);
- X while (fgets(Buf, sizeof(Buf), stdin)) {
- X if (strcmp(Buf, "y\n") == 0 || strcmp(Buf, "yes\n") == 0) {
- X yes = 1;
- X break;
- X }
- X if (strcmp(Buf, "n\n") == 0 || strcmp(Buf, "no\n") == 0) {
- X break;
- X }
- X printf("'y' or 'n' please: ");
- X fflush(stdout);
- X }
- X raw(stdin);
- X if (yes) {
- X sprintf(Buf, "%s %s \"%s!rnews\"", GetConfigProgram(UUX), TempFileName, system_name);
- X system(Buf);
- X }
- X remove(TempFileName);
- X}
- X
- X/*
- X * Finds the requested header in the file. Deletes extra space at the end
- X * and resulting string does not have a newline.
- X */
- X
- Xchar *
- Xfindheader(fp, hdr)
- XFILE *fp;
- Xchar *hdr;
- X{
- X int len = strlen(hdr);
- X
- X if (fp == NULL)
- X return(NULL);
- X
- X rewind(fp);
- X
- X while (fgets(Buf, 256, fp) && Buf[0] != '\n') {
- X if (strncmp(Buf, hdr, len) == 0) {
- X char *ptr = Buf;
- X char *ret = malloc(strlen(ptr + len) + 1);
- X
- X while (ptr[len] == ' ' || ptr[len] == 9 || ptr[len] == '\n')
- X ++len;
- X strcpy(ret, ptr + len);
- X for (len = strlen(ret) - 1; len >= 0; --len) {
- X if (ret[len] != ' ' && ret[len] != 9 && ret[len] != '\n')
- X break;
- X }
- X ++len;
- X ret[len] = 0;
- X return(ret);
- X }
- X }
- X return(NULL);
- X}
- X
- END_OF_FILE
- if test 4278 -ne `wc -c <'uucp2/src/anews/followup.c'`; then
- echo shar: \"'uucp2/src/anews/followup.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/anews/followup.c'
- fi
- if test -f 'uucp2/src/anews/reply.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/anews/reply.c'\"
- else
- echo shar: Extracting \"'uucp2/src/anews/reply.c'\" \(3184 characters\)
- sed "s/^X//" >'uucp2/src/anews/reply.c' <<'END_OF_FILE'
- X
- X/*
- X * REPLY.C
- X *
- X * Reply to sender of article (creates, edits a file, then pipes it through
- X * sendmail)
- X */
- X
- X#include "news.h"
- X#include <time.h>
- X
- Xstatic char Buf[256];
- X
- Xchar *findheader();
- Xchar *findheaderNoNull();
- X
- Xstatic char *TempFileName = "T:anews.post.tmp";
- X
- X/*
- X * NOTE: fp can be NULL
- X */
- X
- Xvoid
- Xreply(cmd, fp, group)
- Xint cmd;
- XFILE *fp;
- Xconst char *group;
- X{
- X FILE *fo = fopen(TempFileName, "w");
- X char *ptr;
- X char *user = FindConfig(USERNAME);
- X char *realname = FindConfig(REALNAME);
- X int yes = 0;
- X time_t t = time(NULL);
- X int seq = GetSequence(0);
- X static char *envuser;
- X static char *envrealname;
- X
- X if (fo == NULL) {
- X printf("can't create %s\n", TempFileName);
- X return;
- X }
- X
- X if (user == NULL || realname == NULL) {
- X printf("Incomplete Configuration, one of:\n");
- X printf("\t%s %s\n", USERNAME, REALNAME);
- X fclose(fo);
- X remove(TempFileName);
- X return;
- X }
- X
- X /*
- X * Enviroment variable overides
- X */
- X
- X if (envuser == NULL)
- X envuser = MallocEnviro("USER");
- X if (envrealname == NULL)
- X envrealname = MallocEnviro("REALNAME");
- X if (envuser)
- X user = envuser;
- X if (envrealname)
- X realname = envrealname;
- X
- X /*
- X * Create email template that can be sent through sendmail, handle
- X * signature and optional included text.
- X */
- X
- X {
- X char *to;
- X
- X if ((to = findheader(fp, "Reply-To:")) == NULL)
- X to = findheader(fp, "From:");
- X if (to) {
- X fprintf(fo, "To: %s\n", to);
- X free(to);
- X } else {
- X fprintf(fo, "To: \n");
- X }
- X }
- X fprintf(fo, "Cc: \n");
- X fprintf(fo, "Subject: ");
- X
- X if (fp)
- X fprintf(fo, "Re: ");
- X if (ptr = findheader(fp, "Subject:")) {
- X char *xp = ptr;
- X if (strnicmp(xp, "re:", 3) == 0)
- X xp += 3;
- X while (*xp == ' ' || *xp == 9)
- X ++xp;
- X fprintf(fo, "%s", xp);
- X free(ptr);
- X }
- X fputs("\n", fo);
- X
- X fputs("\n", fo);
- X
- X if (fp && cmd >= 'A' && cmd <= 'Z') {
- X rewind(fp);
- X while (fgets(Buf, sizeof(Buf), fp) && Buf[0] != '\n');
- X while (fgets(Buf, sizeof(Buf), fp)) {
- X fprintf(fo, ">");
- X fputs(Buf, fo);
- X }
- X }
- X fputs("\n", fo);
- X
- X /*
- X * append signature
- X */
- X
- X {
- X FILE *fi;
- X
- X sprintf(Buf, "%s.signature", user);
- X fi = openlib(Buf);
- X if (fi == NULL)
- X fi = openlib(".signature");
- X if (fi) {
- X fputs("--\n", fo);
- X while (fgets(Buf, sizeof(Buf), fi))
- X fputs(Buf, fo);
- X fclose(fi);
- X } else {
- X puts("Warning, no .signature file!");
- X }
- X }
- X
- X fclose(fo);
- X
- X /*
- X * Edit the file
- X */
- X
- X sprintf(Buf, "%s %s", GetConfig(NEWSEDITOR, GetConfig(EDITOR, "dme")), TempFileName);
- X system(Buf);
- X
- X /*
- X * want to post this?
- X */
- X
- X cooked(stdin);
- X printf("Do you want to send this? 'y' or 'n' :");
- X fflush(stdout);
- X while (fgets(Buf, sizeof(Buf), stdin)) {
- X if (strcmp(Buf, "y\n") == 0 || strcmp(Buf, "yes\n") == 0) {
- X yes = 1;
- X break;
- X }
- X if (strcmp(Buf, "n\n") == 0 || strcmp(Buf, "no\n") == 0) {
- X break;
- X }
- X printf("'y' or 'n' please: ");
- X fflush(stdout);
- X }
- X
- X raw(stdin);
- X if (yes) {
- X sprintf(Buf, "%s < %s -f %s", GetConfigProgram(SENDMAIL), TempFileName, user);
- X system(Buf);
- X remove(TempFileName);
- X } else {
- X printf("File left as %s\n", TempFileName);
- X }
- X}
- X
- END_OF_FILE
- if test 3184 -ne `wc -c <'uucp2/src/anews/reply.c'`; then
- echo shar: \"'uucp2/src/anews/reply.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/anews/reply.c'
- fi
- if test -f 'uucp2/src/dmail/do_lists.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/dmail/do_lists.c'\"
- else
- echo shar: Extracting \"'uucp2/src/dmail/do_lists.c'\" \(4162 characters\)
- sed "s/^X//" >'uucp2/src/dmail/do_lists.c' <<'END_OF_FILE'
- X
- X/*
- X * DO_LISTS.C
- X *
- X * $Header: Beta:src/uucp/src/dmail/RCS/do_lists.c,v 1.1 90/02/02 12:03:33 dillon Exp Locker: dillon $
- X *
- X * (C) Copyright 1985-1990 by Matthew Dillon, All Rights Reserved.
- X *
- X * Global Routines: DO_SETLIST()
- X * DO_LIST()
- X * DO_SELECT()
- X * DO_DEFER()
- X *
- X * Static Routines: None.
- X *
- X * LIST associated commands.
- X *
- X */
- X
- X#include <stdio.h>
- X#include "dmail.h"
- X
- X
- Xdo_setlist(str)
- Xchar *str;
- X{
- X int i, fw, idx, localecho = 1;
- X int sac = 1;
- X
- X push_break();
- X if (ac > sac && strcmp (av[sac], "-s") == 0) {
- X ++sac;
- X localecho = 0;
- X }
- X hold_load();
- X if (ac > sac) {
- X Listsize = 0;
- X for (i = sac; i < ac; ++i) {
- X fw = atoi(av[i]);
- X if (fw > 4096)
- X fw = 4096;
- X if (fw < 0 || (*av[i] < '0' || *av[i] > '9'))
- X fw = 20;
- X else
- X ++i;
- X if (i >= ac)
- X continue;
- X idx = get_extra_ovr (av[i]);
- X if (idx < 0) {
- X printf ("To many entries, cannot load: %s\n", av[i]);
- X fflush (stdout);
- X continue;
- X }
- X header[Listsize] = idx;
- X width[Listsize] = fw;
- X ++Listsize;
- X }
- X }
- X nohold_load();
- X pop_break();
- X if (localecho) {
- X puts ("");
- X printf ("Entry Width Field\n\n");
- X for (i = 0; i < Listsize; ++i)
- X printf ("%-6d %-5d %s\n", i, width[i], Find[header[i]].search);
- X puts ("");
- X }
- X return (1);
- X}
- X
- X
- X/*
- X * Pre-position # 0 > Current article
- X * 1 - Read already
- X */
- X
- Xdo_rlist()
- X{
- X int num = 20;
- X int istart = Current, iend = Current;
- X short dir = 1;
- X short try;
- X char buf[64];
- X
- X if (av[1])
- X num = atoi(av[1]);
- X if (num < 0) {
- X dir = -1;
- X num = -num;
- X }
- X for (try = 0; try < 2 && num; ++try, (dir = -dir)) {
- X int i;
- X if (dir < 0) {
- X for (i = Current; i >= 0 && num; --i) {
- X if (Entry[i].no && !(Entry[i].status & ST_DELETED)) {
- X istart = i;
- X --num;
- X }
- X }
- X } else {
- X for (i = Current; i < Entries && num; ++i) {
- X if (Entry[i].no && !(Entry[i].status & ST_DELETED)) {
- X iend = i;
- X --num;
- X }
- X }
- X }
- X }
- X if (istart != iend) {
- X sprintf(buf, "%d-%d", Entry[istart].no, Entry[iend].no);
- X ac = 2;
- X av[1] = buf;
- X return(do_list());
- X } else {
- X return(-1);
- X }
- X}
- X
- Xdo_list()
- X{
- X int i, j;
- X static char curr[10] = { " " };
- X
- X if (ac == 1) {
- X av[1] = "all";
- X ++ac;
- X }
- X if (push_base()) {
- X push_break();
- X pop_base();
- X PAGER (-1);
- X pop_break();
- X return (-1);
- X }
- X PAGER (0);
- X FPAGER ("\n ");
- X for (j = 0; j < Listsize; ++j) {
- X if (width[j]) {
- X sprintf (Puf, "%-*.*s",
- X 2 + width[j],
- X 2 + width[j],
- X Find[header[j]].search);
- X FPAGER (Puf);
- X }
- X }
- X FPAGER ("\n");
- X rewind_range (1);
- X while (i = get_range()) {
- X i = indexof(i);
- X if (Entry[i].no && ((Entry[i].status & ST_DELETED) == 0)) {
- X curr[0] = (Entry[i].status & ST_TAG) ? 'T' : ' ';
- X curr[1] = (i == Current) ? '>' : ' ';
- X curr[2] = (Entry[i].status & ST_READ) ? 'r' : ' ';
- X curr[3] = (Entry[i].status & ST_STORED) ? 'w' : ' ';
- X sprintf (Puf, "%s%-3d", curr, Entry[i].no);
- X FPAGER (Puf);
- X for (j = 0; j < Listsize; ++j) {
- X if (width[j]) {
- X sprintf(Puf, " %-*.*s",
- X width[j],
- X width[j],
- X Entry[i].fields[header[j]]);
- X FPAGER (Puf);
- X }
- X }
- X FPAGER ("\n");
- X }
- X }
- X FPAGER ("\n");
- X PAGER (-1);
- X pop_base();
- X return (1);
- X}
- X
- X
- X
- Xdo_select(str, mode)
- Xchar *str;
- X{
- X int ret = 1;
- X int localecho = 1;
- X int avi = 1;
- X int scr;
- X
- X if (ac == 1)
- X return (1);
- X
- X SelAll = 0;
- X
- X if (strcmp (av[avi], "-s") == 0) {
- X localecho = 0;
- X ++avi;
- X --ac;
- X }
- X switch (ac) {
- X case 2:
- X SelAll = 1;
- X if (localecho)
- X puts ("SELECT ALL");
- X ret = m_select (Nulav, mode);
- X break;
- X case 1:
- X break;
- X default:
- X ret = m_select (av + avi, mode);
- X scr = indexof(0);
- X if (scr > 0 && localecho)
- X printf ("%d Entries selected\n", Entry[scr].no);
- X break;
- X }
- X if (ret < 0 && localecho) {
- X puts ("Null field");
- X return (-1);
- X }
- X return (1);
- X}
- X
- X
- Xdo_defer()
- X{
- X register int i, j;
- X
- X push_break();
- X j = 1;
- X for (i = 0; i < Entries; ++i) {
- X if (Entry[i].no)
- X Entry[i].no = (Entry[i].status & ST_READ) ? 0 : j++;
- X }
- X pop_break();
- X return (1);
- X}
- X
- END_OF_FILE
- if test 4162 -ne `wc -c <'uucp2/src/dmail/do_lists.c'`; then
- echo shar: \"'uucp2/src/dmail/do_lists.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/dmail/do_lists.c'
- fi
- if test -f 'uucp2/src/dmail/range.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/dmail/range.c'\"
- else
- echo shar: Extracting \"'uucp2/src/dmail/range.c'\" \(3191 characters\)
- sed "s/^X//" >'uucp2/src/dmail/range.c' <<'END_OF_FILE'
- X
- X/*
- X * RANGE.C
- X *
- X * $Header: Beta:src/uucp/src/dmail/RCS/range.c,v 1.1 90/02/02 12:03:54 dillon Exp Locker: dillon $
- X *
- X * (C) Copyright 1985-1990 by Matthew Dillon, All Rights Reserved.
- X *
- X * Global Routines: REWIND_RANGE()
- X * GET_RANGE()
- X * SINGLE_POSITION()
- X *
- X * Static Routines: None.
- X *
- X *
- X */
- X
- X#include <stdio.h>
- X#include "dmail.h"
- X
- X
- Xstatic int range_ac;
- Xstatic int in, start, end;
- X
- Xstruct RANOP {
- X char *name;
- X int status, kstatus;
- X};
- X
- Xstatic struct RANOP Ranop[] = {
- X "all", 0, 0,
- X "tag", ST_TAG, ST_DELETED,
- X "wri", ST_STORED, ST_DELETED,
- X "del", ST_DELETED, 0,
- X "mar", ST_READ, ST_DELETED,
- X "unt", 0, ST_DELETED | ST_TAG,
- X "unw", 0, ST_DELETED | ST_STORED,
- X "und", 0, ST_DELETED,
- X "unm", 0, ST_DELETED | ST_READ,
- X NULL , 0, 0 };
- X
- Xvoid
- Xrewind_range(beg)
- X{
- X Silence = 0;
- X range_ac = beg;
- X
- X if (range_ac >= ac) {
- X start = (Current >= 0) ? Entry[Current].no : 0;
- X end = start;
- X in = 1;
- X } else {
- X in = 0;
- X }
- X}
- X
- X
- Xget_range()
- X{
- X register char *ptr;
- X register int i;
- X static int status; /* Status items required */
- X static int kstatus; /* Status items which cannot be present */
- X
- Xagain:
- X if (in && start <= end) {
- X i = indexof(start++);
- X if (i < 0 || (Entry[i].status & status) != status ||
- X (Entry[i].status & kstatus))
- X goto again;
- X return (start - 1);
- X }
- X in = status = kstatus = 0;
- X if (range_ac >= ac)
- X return (0);
- X ptr = av[range_ac++];
- X if (*ptr == '-') {
- X if (xstrncmp (ptr, "-s", 2) == 0) {
- X Silence = 1;
- X goto again;
- X }
- X start = 1;
- X ++ptr;
- X goto dash;
- X }
- X if (*ptr < '0' || *ptr > '9') {
- X start = 1;
- X end = 0;
- X for (i = 0; Ranop[i].name; ++i) {
- X if (xstrncmp (ptr, Ranop[i].name, 3) == 0) {
- X status = Ranop[i].status;
- X kstatus = Ranop[i].kstatus;
- X goto imprange;
- X }
- X }
- X goto again;
- X }
- X start = atoi(ptr);
- X while (*(++ptr)) {
- X if (*ptr == '-') {
- X ++ptr;
- X goto dash;
- X }
- X }
- X if (range_ac >= ac)
- X return (start);
- X if (*av[range_ac] == '-') {
- X ptr = av[range_ac++] + 1;
- X goto dash;
- X }
- X return (start);
- Xdash:
- X if (*ptr) {
- X end = atoi(ptr);
- X goto imprange;
- X }
- X if (range_ac >= ac) {
- X end = 0;
- X goto imprange;
- X }
- X end = atoi(av[range_ac++]);
- Ximprange:
- X if (end == 0) {
- X end = indexof (0);
- X if (end < 0)
- X return (0);
- X end = Entry[end].no;
- X }
- X if (start > end) {
- X printf ("Bad Range: %s\n", av[range_ac - 1]);
- X return (0);
- X }
- X in = 1;
- X goto again;
- X}
- X
- X
- Xsingle_position()
- X{
- X int old = Current;
- X
- X switch (ac) {
- X case 1:
- X break;
- X case 2:
- X if (*av[1] == '\0' || (*av[1] == ' ' && strlen(av[1]) == 1))
- X break;
- X Current = indexof (atoi(av[1]));
- X if (Current < 0) {
- X Current = old;
- X puts ("Out of Range, 0 will take you to the last entry");
- X return (-1);
- X }
- X break;
- X default:
- X puts ("Range not implemented (yet?)");
- X return (-1);
- X }
- X while (Current < Entries && Entry[Current].no == 0)
- X ++Current;
- X if (Current >= Entries) {
- X Current = old;
- X puts ("No More Messages");
- X return (-1);
- X }
- X position_current();
- X return (1);
- X}
- X
- X
- END_OF_FILE
- if test 3191 -ne `wc -c <'uucp2/src/dmail/range.c'`; then
- echo shar: \"'uucp2/src/dmail/range.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/dmail/range.c'
- fi
- if test -f 'uucp2/src/lib/config.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/lib/config.c'\"
- else
- echo shar: Extracting \"'uucp2/src/lib/config.c'\" \(3478 characters\)
- sed "s/^X//" >'uucp2/src/lib/config.c' <<'END_OF_FILE'
- X
- X/*
- X * CONFIG.C
- X *
- X * $Header: Beta:src/uucp/src/lib/RCS/config.c,v 1.1 90/02/02 12:08:37 dillon Exp Locker: dillon $
- X *
- X * (C) Copyright 1989-1990 by Matthew Dillon, All Rights Reserved.
- X *
- X * Extract fields from UULIB:Config
- X */
- X
- X#include <stdio.h>
- X#include <stdlib.h>
- X#include <fcntl.h>
- X#include "config.h"
- X
- XPrototype char *FindConfig(const char *);
- XPrototype char *GetConfig(const char *, char *);
- XPrototype char *GetConfigDir(char *);
- XPrototype char *GetConfigProgram(char *);
- XPrototype char *MakeConfigPath(const char *, const char *);
- XPrototype char *MallocEnviro(const char *);
- XPrototype FILE *openlib(const char *);
- XPrototype FILE *openlib_write(const char *);
- X
- X#define CTLZ ('z'&0x1F)
- X
- Xstatic char *ConfBuf = NULL;
- X
- Xchar *
- XFindConfig(field)
- Xconst char *field;
- X{
- X char *str;
- X short flen = strlen(field);
- X
- X if (ConfBuf == NULL) {
- X FILE *fi;
- X fi = fopen("S:UUConfig", "r");
- X if (fi == NULL)
- X fi = fopen("UULIB:Config", "r");
- X if (fi) {
- X long buflen;
- X fseek(fi, 0L, 2);
- X buflen = ftell(fi);
- X fseek(fi, 0L, 0);
- X if (buflen > 0 && (ConfBuf = malloc(buflen + 1))) {
- X fread(ConfBuf, buflen, 1, fi);
- X ConfBuf[buflen] = CTLZ; /* can't use \0 */
- X for (str = ConfBuf; *str; ++str) {
- X char *bup;
- X if (*str == '\n') { /* make separate strs */
- X *str = 0;
- X /* remove white space at end */
- X for (bup = str - 1; bup >= ConfBuf && (*bup == ' ' || *bup == 9); --bup)
- X *bup = 0;
- X }
- X }
- X } else {
- X ConfBuf = NULL;
- X }
- X } else {
- X fprintf(stderr, "Couldn't open S:UUConfig or UULIB:Config\n");
- X }
- X }
- X if (ConfBuf == NULL)
- X return(NULL);
- X /*
- X * Search ConfBuf for Field<space/tab>
- X */
- X
- X for (str = ConfBuf; *str != CTLZ; str += strlen(str) + 1) {
- X if (*str == 0 || *str == '#')
- X continue;
- X if (strncmp(str, field, flen) == 0 && (str[flen] == ' ' || str[flen] == '\t')) {
- X str += flen;
- X while (*str == ' ' || *str == 9)
- X ++str;
- X return(str);
- X }
- X }
- X return(NULL);
- X}
- X
- Xchar *
- XGetConfig(field, def)
- Xconst char *field;
- Xchar *def;
- X{
- X char *result = FindConfig(field);
- X
- X if (result == NULL)
- X result = def;
- X return(result);
- X}
- X
- Xchar *
- XGetConfigDir(field)
- Xchar *field;
- X{
- X char *result = FindConfig(field);
- X
- X if (result == NULL)
- X result = field + strlen(field) + 1;
- X return(result);
- X}
- X
- Xchar *
- XGetConfigProgram(field)
- Xchar *field;
- X{
- X char *result = FindConfig(field);
- X if (result == NULL)
- X result = field;
- X return(result);
- X}
- X
- Xchar *
- XMakeConfigPath(field, trailer)
- Xconst char *field;
- Xconst char *trailer;
- X{
- X static char Buf[512];
- X char *result = GetConfigDir(field);
- X short len = strlen(result) - 1;
- X
- X if (len > 0 && result[len] == '/' || result[len] == ':')
- X sprintf(Buf, "%s%s", result, trailer);
- X else
- X sprintf(Buf, "%s/%s", result, trailer);
- X return(Buf);
- X}
- X
- Xchar *
- XMallocEnviro(envname)
- Xconst char *envname;
- X{
- X int fd;
- X int len;
- X char *tmp = malloc(strlen(envname) + 32);
- X
- X sprintf(tmp, "ENV:%s", envname);
- X fd = open(tmp, O_RDONLY);
- X free(tmp);
- X
- X if (fd < 0)
- X return(NULL);
- X len = lseek(fd, 0L, 2);
- X lseek(fd, 0L, 0);
- X if (len >= 0) {
- X tmp = malloc(len + 1);
- X read(fd, tmp, len);
- X tmp[len] = 0;
- X } else {
- X tmp = NULL;
- X }
- X close(fd);
- X return(tmp);
- X}
- X
- XFILE *
- Xopenlib(filename)
- Xconst char *filename;
- X{
- X return (fopen(MakeConfigPath(UULIB, filename), "r"));
- X}
- X
- XFILE *
- Xopenlib_write(filename)
- Xconst char *filename;
- X{
- X return (fopen(MakeConfigPath(UULIB, filename), "w"));
- X}
- X
- END_OF_FILE
- if test 3478 -ne `wc -c <'uucp2/src/lib/config.c'`; then
- echo shar: \"'uucp2/src/lib/config.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/lib/config.c'
- fi
- if test -f 'uucp2/src/lib/list_sort.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/lib/list_sort.c'\"
- else
- echo shar: Extracting \"'uucp2/src/lib/list_sort.c'\" \(3949 characters\)
- sed "s/^X//" >'uucp2/src/lib/list_sort.c' <<'END_OF_FILE'
- X
- X/*
- X * LIST_SORT.C
- X *
- X * list_sort(list, compare_routine) -> sorted_list
- X *
- X * Assumes a list of structures, with a pointer to "next" as the first
- X * field. It reorders the list into ascending order, and returns the
- X * new first node's address. It is order N log(N).
- X *
- X * The compare routine should return positive if the items are in order,
- X * and non-positive if they are not. If the compare routine returns zero
- X * in case of equality, the sort will be stable.
- X */
- X
- X/* This routine depends upon compiler-dependant struct layout, but this
- X * assumption is likely to be fairly commonly valid.
- X */
- X
- X#define _LIST_SORT_C
- X
- X#include <stdio.h>
- X#include "version.h"
- X
- XIDENT(".01");
- X
- Xtypedef struct node_struct {
- X struct node_struct *next;
- X} node_type;
- X
- Xtypedef int (*cf_type)(node_type *, node_type *);
- X
- XLocal node_type *list_sort(node_type *, cf_type);
- X
- Xnode_type *
- Xlist_sort(node_type *list, cf_type cmp)
- X{
- X struct node_struct *new[2]; /* back of new stuff */
- X struct node_struct *old[2]; /* front of old stuff */
- X int n; /* current new list */
- X int o; /* current old list */
- X long m, hm; /* m is merge length, hm is half of that */
- X long count[2]; /* counts entries drawn from "old" lists */
- X node_type front[2]; /* artificial front-of-list */
- X
- X /*
- X * The basic notion of this sort is to make sorted sublists longer and
- X * longer by merging. On the Nth pass through the list, sorted
- X * sublists of length 2^(N-1) are produced. Eventually, the entire
- X * list is sorted, in log2(N)+1 passes through the list. There is
- X * extra bookkeeping overhead, but minimal extra storage space needed.
- X * Counts and clever pointer management substitute for extra "glue"
- X * nodes.
- X *
- X * while more than one list
- X * while not at end of composite lists
- X * for each merge_length(m) block
- X * merge lists onto current output list
- X * toggle current output list
- X */
- X
- X front[0].next = 0;
- X front[1].next = list;
- X
- X for (hm = 0, m = 1; front[1].next != 0; hm = m, m <<= 1) {
- X /* log2(N)+1 times through (since m doubles every time) */
- X
- X new[0] = &front[0]; old[0] = front[0].next;
- X new[1] = &front[1]; old[1] = front[1].next;
- X n = 0;
- X count[0] = count[1] = 0;
- X
- X for (;;) {
- X /*
- X * N times through (each time through consumes
- X * one item from one or the other of the old lists)
- X */
- X
- X if (old[0] == 0) {
- X /*
- X * First composite input list exhausted...
- X * copy second list onto output, quitting
- X * if second list is at end.
- X */
- X
- X new[n] = new[n]->next = old[1];
- X if ((old[1] = old[1]->next) == 0)
- X break;
- X if (++count[1] >= hm)
- X n = 1 - n, count[0] = count[1] = 0;
- X } else if (old[1] == 0) {
- X /*
- X * Second composite input list exhausted...
- X * copy first list onto output, quitting
- X * if first list is at end.
- X */
- X
- X new[n] = new[n]->next = old[0];
- X if ((old[0] = old[0]->next) == 0)
- X break;
- X if (++count[0] >= hm)
- X n = 1 - n, count[0] = count[1] = 0;
- X } else if (count[0] >= hm) {
- X /*
- X * First logical input list exhausted...
- X * copy second list onto output, swapping
- X * output list if second input list ends.
- X */
- X
- X new[n] = new[n]->next = old[1];
- X old[1] = old[1]->next;
- X if (++count[1] >= hm)
- X n = 1 - n, count[0] = count[1] = 0;
- X } else if (count[1] >= hm) {
- X /*
- X * Second logical input list exhausted...
- X * copy first list onto output, swapping
- X * output list if first input list ends.
- X */
- X
- X new[n] = new[n]->next = old[0];
- X old[0] = old[0]->next;
- X if (++count[0] >= hm)
- X n = 1 - n, count[0] = count[1] = 0;
- X } else {
- X /*
- X * Compare the two items at the heads of
- X * the input lists, and put the smaller
- X * on the current output list.
- X */
- X
- X o = (*cmp)(old[0], old[1]) > 0;
- X new[n] = new[n]->next = old[o];
- X old[o] = old[o]->next;
- X ++count[o];
- X }
- X }
- X new[0]->next = new[1]->next = 0;
- X }
- X return front[0].next;
- X}
- X
- END_OF_FILE
- if test 3949 -ne `wc -c <'uucp2/src/lib/list_sort.c'`; then
- echo shar: \"'uucp2/src/lib/list_sort.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/lib/list_sort.c'
- fi
- if test -f 'uucp2/src/news/postnews.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/news/postnews.c'\"
- else
- echo shar: Extracting \"'uucp2/src/news/postnews.c'\" \(3427 characters\)
- sed "s/^X//" >'uucp2/src/news/postnews.c' <<'END_OF_FILE'
- X
- X/*
- X * POSTNEWS.C
- X *
- X * POSTNEWS <newsfile -f user -r "realname" -R reffile (BATCH news poster)
- X * -x file (delete file when done)
- X *
- X * If not specified, obtains user/realname from USERNAME and REALNAME
- X * enviroment variables. If either does not exist then gets it from
- X * the UserName and RealName config entries.
- X *
- X * If -R is specified the reffile is included in the header list (usually
- X * contains References: generated by DNews)
- X */
- X
- X#include <stdio.h>
- X#include <stdlib.h>
- X#include <time.h>
- X#include "config.h"
- X#include "version.h"
- X
- XIDENT(".03");
- X
- Xchar TmpBuf[2048];
- Xchar *DelFile[32];
- Xshort Di;
- X
- Xvoid PostNews();
- X
- Xmain(ac, av)
- Xchar *av[];
- X{
- X short i;
- X char *from = NULL;
- X char *real = NULL;
- X char *reffile = NULL;
- X FILE *rfi;
- X
- X for (i = 1; i < ac; ++i) {
- X char *ptr = av[i];
- X if (*ptr == '-') {
- X
- X ptr += 2;
- X
- X switch(ptr[-1]) {
- X case 'f':
- X if (*ptr == 0)
- X ptr = av[++i];
- X from = ptr;
- X break;
- X case 'r':
- X if (*ptr == 0)
- X ptr = av[++i];
- X real = ptr;
- X break;
- X case 'R':
- X if (*ptr == 0)
- X ptr = av[++i];
- X reffile = ptr;
- X break;
- X case 'x':
- X if (*ptr == 0)
- X ptr = av[++i];
- X DelFile[Di++] = ptr;
- X break;
- X default:
- X printf("Unknown option: %s\n", ptr - 2);
- X exit(1);
- X }
- X } else {
- X printf("Illegal argument: %s\n", ptr);
- X exit(1);
- X }
- X }
- X if (i > ac) {
- X puts("Expected argument to option");
- X exit(1);
- X }
- X if (from == NULL)
- X from = GetUserName();
- X if (real == NULL)
- X real = GetRealName();
- X
- X if (reffile)
- X rfi = fopen(reffile, "r");
- X else
- X rfi = NULL;
- X
- X LockFile("PostNews-UPDATE");
- X PostNews(stdin, rfi, from, real);
- X UnLockFile("PostNews-UPDATE");
- X
- X if (rfi)
- X fclose(rfi);
- X
- X while (--Di >= 0)
- X remove(DelFile[Di]);
- X
- X return(0);
- X}
- X
- Xvoid
- XPostNews(fi, rfi, user, realname)
- XFILE *fi;
- XFILE *rfi;
- Xchar *user;
- Xchar *realname;
- X{
- X char *nodename = FindConfig(NODENAME);
- X char *system_name = FindConfig(NEWSFEED);
- X char *domain = FindConfig(DOMAINNAME);
- X int seq = GetSequence(0);
- X char tfname[32];
- X time_t t = time(NULL);
- X FILE *fo;
- X
- X sprintf(tfname, "T:post-%d", seq);
- X
- X if (nodename == NULL || system_name == NULL || user == NULL || realname == NULL) {
- X puts("Incomplete configuration! can't post news");
- X return;
- X }
- X if (domain == NULL)
- X domain = ".UUCP";
- X
- X fo = fopen(tfname, "w");
- X if (fo == NULL) {
- X printf("Unable to create %s\n", tfname);
- X return;
- X }
- X
- X /*
- X * Create the actual news file to fo, copying appropriate sections of infile.
- X */
- X
- X fprintf(fo, "Path: %s!%s\n", nodename, user);
- X fprintf(fo, "From: %s@%s%s (%s)\n", user, nodename, domain, realname);
- X fprintf(fo, "Message-ID: <%s.%04d@%s%s>\n", user, seq, nodename, domain);
- X
- X /*
- X * user headers
- X */
- X
- X while (fgets(TmpBuf, sizeof(TmpBuf), fi) && TmpBuf[0] != '\n')
- X fputs(TmpBuf, fo);
- X
- X /*
- X * system headers (news program -R option to postnews)
- X * (usually References:)
- X */
- X
- X if (rfi) {
- X while (fgets(TmpBuf, sizeof(TmpBuf), rfi))
- X fputs(TmpBuf, fo);
- X }
- X
- X /*
- X * more headers
- X */
- X
- X fprintf(fo, "Date: %s", ctime(&t));
- X
- X /*
- X * remainder of message
- X */
- X
- X fprintf(fo, "\n");
- X
- X while (fgets(TmpBuf, sizeof(TmpBuf), fi))
- X fputs(TmpBuf, fo);
- X
- X fclose(fo);
- X
- X sprintf(TmpBuf, "%s %s \"%s!rnews\"", GetConfigProgram(UUX), tfname, system_name);
- X system(TmpBuf);
- X remove(tfname);
- X}
- X
- END_OF_FILE
- if test 3427 -ne `wc -c <'uucp2/src/news/postnews.c'`; then
- echo shar: \"'uucp2/src/news/postnews.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/news/postnews.c'
- fi
- if test -f 'uucp2/src/unix/tarsplit.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/unix/tarsplit.c'\"
- else
- echo shar: Extracting \"'uucp2/src/unix/tarsplit.c'\" \(4031 characters\)
- sed "s/^X//" >'uucp2/src/unix/tarsplit.c' <<'END_OF_FILE'
- X
- X/*
- X * TARSPLIT.C
- X *
- X * $Header: Beta:src/uucp/src/compress/RCS/tarsplit.c,v 1.1 90/02/02 11:48:06 dillon Exp Locker: dillon $
- X *
- X * TarSplit -- split up tar files (creating directories as needed)
- X *
- X * usage: TarSplit [pathname]
- X *
- X * semantics: splits up tar file taken from stdin (or pathname, if
- X * specified) and creates the files therein under the working data
- X * directory.
- X *
- X * AmigaDOS Version - no support for stdin.
- X */
- X
- X#include <stdio.h>
- X#include "version.h"
- X
- XIDENT(".00");
- X
- X#ifdef AMIGA
- X#include <stdlib.h>
- X#include <exec/types.h>
- X#ifdef LATTICE
- X#include <proto/all.h>
- X#else
- X#include "protos.h"
- X#endif
- Xtypedef int bool ;
- Xbool ChkSumOK() ;
- X#include <libraries/dosextens.h>
- X#else
- X#include <modes.h>
- X#include <bool.h>
- X#define DIRMODE (S_IREAD | S_IWRITE | S_IEXEC | S_IOREAD | S_IOEXEC)
- X#endif
- X#define TBLOCK 512
- X#define NAMSIZ 100
- X
- Xunion hblock {
- X char dummy[TBLOCK];
- X struct header {
- X char name[NAMSIZ];
- X char mode[8];
- X char uid[8];
- X char gid[8];
- X char size[12];
- X char mtime[12];
- X char chksum[8];
- X char linkflag;
- X char linkname[NAMSIZ];
- X } dbuf;
- X};
- X
- X#define BLKSIZE (sizeof (union hblock))
- X#define HARDLINK '1'
- X#define SYMBLINK '2'
- X#define NORMAL '\0'
- X
- Xvoid DoFile();
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar *argv[];
- X{
- X FILE *TarFP;
- X union hblock TarBlock;
- X
- X#ifndef AMIGA
- X /* make the compiler happy about formatted I/O for longs... */
- X pflinit();
- X#endif
- X
- X switch(argc) {
- X#ifndef AMIGA
- X case 1:
- X TarFP = stdin;
- X break;
- X#endif
- X case 2:
- X if ((TarFP = fopen(argv[1], "r")) == NULL) {
- X fprintf(stderr, "TarSplit: can't open %s\n", argv[1]);
- X exit(1);
- X }
- X break;
- X default:
- X fprintf(stderr, "usage: TarSplit [pathname]\n");
- X exit(1);
- X }
- X
- X for (;;) {
- X if (fread((char *)&TarBlock, BLKSIZE, 1, TarFP) == NULL) {
- X fprintf(stderr, "TarSplit: premature EOF\n");
- X exit(1);
- X } else if (IsZero(&TarBlock)) {
- X while (fread((char *)&TarBlock, BLKSIZE, 1, TarFP) != NULL)
- X ;
- X break;
- X } else
- X DoFile(&TarBlock, TarFP);
- X }
- X
- X}
- X
- Xbool
- XIsZero(block)
- Xunion hblock *block;
- X{
- X int i;
- X char *cblock;
- X
- X cblock = block->dummy;
- X for (i = 0; i < TBLOCK; i++)
- X if (*cblock++ != '\0')
- X return(FALSE);
- X
- X return (TRUE);
- X
- X}
- X
- Xvoid
- XDoFile(block, TarFP)
- Xunion hblock *block;
- XFILE *TarFP;
- X{
- X long FSize;
- X char FName[NAMSIZ], *RefName;
- X int i;
- X bool IsDir, OpenOK;
- X FILE *NewFP;
- X
- X if (!ChkSumOK(block)) {
- X fprintf(stderr, "TarSplit: bad checksum, name %s?\n",
- X block->dbuf.name);
- X exit(1);
- X }
- X
- X switch(block->dbuf.linkflag) {
- X case HARDLINK:
- X case SYMBLINK:
- X fprintf(stderr, "TarSplit: can't handle links\n");
- X exit(1);
- X case NORMAL:
- X break;
- X default:
- X fprintf(stderr, "TarSplit: unknown linkflag\n");
- X exit(1);
- X }
- X
- X#ifdef AMIGA
- X if (sscanf(block->dbuf.size, "%12lo", &FSize) != 1) {
- X#else
- X if (sscanf(block->dbuf.size, "%12O", &FSize) != 1) {
- X#endif
- X fprintf(stderr, "TarSplit: bad size\n");
- X exit(1);
- X }
- X
- X for (i = 0, RefName = block->dbuf.name; *RefName; i++, RefName++)
- X FName[i] = *RefName;
- X
- X if (IsDir = (*(RefName - 1) == '/')) {
- X FName[i - 1] = '\0';
- X if (strcmp(FName, ".") == 0)
- X OpenOK = TRUE;
- X else
- X#ifdef AMIGA
- X {
- X BPTR Lock;
- X OpenOK = (Lock = CreateDir(FName)) != 0;
- X UnLock(Lock) ;
- X }
- X#else
- X OpenOK = mknod(FName, DIRMODE) == 0;
- X#endif
- X } else {
- X FName[i] = '\0';
- X OpenOK = (NewFP = fopen(FName, "w")) != NULL;
- X }
- X
- X if (!OpenOK) {
- X fprintf(stderr, "TarSplit: can't create %s\n", FName);
- X exit(1);
- X }
- X
- X for (; FSize > 0; FSize -= TBLOCK) {
- X if (fread((char *)block, BLKSIZE, 1, TarFP) == NULL) {
- X fprintf(stderr, "TarSplit: premature EOF\n");
- X exit(1);
- X }
- X if (!IsDir)
- X fwrite(block->dummy, 1,
- X (FSize > TBLOCK ? TBLOCK : (int) FSize), NewFP);
- X }
- X
- X if (!IsDir)
- X fclose(NewFP);
- X}
- X
- Xbool
- XChkSumOK(block)
- Xunion hblock *block;
- X{
- X long Accum, ChkSumVal;
- X int i;
- X
- X#ifdef AMIGA
- X sscanf(block->dbuf.chksum, "%8lo", &ChkSumVal);
- X#else
- X sscanf(block->dbuf.chksum, "%8O", &ChkSumVal);
- X#endif
- X for (i = 0; i < 8; i++)
- X block->dbuf.chksum[i] = ' ';
- X
- X Accum = 0;
- X for (i = 0; i < TBLOCK; i++)
- X Accum += 0xff & block->dummy[i];
- X
- X return(Accum == ChkSumVal);
- X
- X}
- END_OF_FILE
- if test 4031 -ne `wc -c <'uucp2/src/unix/tarsplit.c'`; then
- echo shar: \"'uucp2/src/unix/tarsplit.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/unix/tarsplit.c'
- fi
- if test -f 'uucp2/src/unix/uudecode.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/unix/uudecode.c'\"
- else
- echo shar: Extracting \"'uucp2/src/unix/uudecode.c'\" \(3321 characters\)
- sed "s/^X//" >'uucp2/src/unix/uudecode.c' <<'END_OF_FILE'
- X
- X/*
- X * UUDECODE.C
- X *
- X * $Header: Beta:src/uucp/src/compress/RCS/uudecode.c,v 1.1 90/02/02 11:48:08 dillon Exp Locker: dillon $
- X *
- X * uudecode [input]
- X *
- X * create the specified file, decoding as you go.
- X * used with uuencode.
- X */
- X
- X#include <stdio.h>
- X#include "version.h"
- X
- XIDENT(".00");
- X
- X#ifdef UNIX
- X# include <pwd.h>
- X# include <sys/types.h>
- X# include <sys/stat.h>
- X#endif
- X
- X#ifdef VMS
- X# include <types.h>
- X# include <stat.h>
- X#endif
- X
- X/* single character decode */
- X#define DEC(c) (((c) - ' ') & 077)
- X
- Xvoid outdec();
- Xvoid decode();
- Xvoid xerror();
- X
- Xvoid
- Xmain(argc, argv)
- Xchar **argv;
- X{
- X FILE *in, *out;
- X#ifdef UNIX | VMS
- X struct stat sbuf;
- X#endif
- X int mode;
- X char dest[128];
- X char buf[80];
- X
- X /* optional input arg */
- X if (argc > 1) {
- X if ((in = fopen(argv[1], "r")) == NULL) {
- X xerror(argv[1]);
- X exit(1);
- X }
- X argv++; argc--;
- X } else
- X in = stdin;
- X
- X if (argc != 1) {
- X printf("Usage: uudecode [infile]\n");
- X exit(2);
- X }
- X
- X /* search for header line */
- X for (;;) {
- X if (fgets(buf, sizeof buf, in) == NULL) {
- X fprintf(stderr, "No begin line\n");
- X exit(3);
- X }
- X if (strncmp(buf, "begin ", 6) == 0)
- X break;
- X }
- X sscanf(buf, "begin %o %s", &mode, dest);
- X
- X#ifdef UNIX
- X /* handle ~user/file format */
- X if (dest[0] == '~') {
- X char *sl;
- X struct passwd *getpwnam();
- X char *index();
- X struct passwd *user;
- X char dnbuf[100];
- X
- X sl = index(dest, '/');
- X if (sl == NULL) {
- X fprintf(stderr, "Illegal ~user\n");
- X exit(3);
- X }
- X *sl++ = 0;
- X user = getpwnam(dest+1);
- X if (user == NULL) {
- X fprintf(stderr, "No such user as %s\n", dest);
- X exit(4);
- X }
- X strcpy(dnbuf, user->pw_dir);
- X strcat(dnbuf, "/");
- X strcat(dnbuf, sl);
- X strcpy(dest, dnbuf);
- X }
- X#endif /* UNIX */
- X
- X /* create output file */
- X out = fopen(dest, "w");
- X if (out == NULL) {
- X xerror(dest);
- X exit(4);
- X }
- X#ifdef UNIX | VMS
- X chmod(dest, mode);
- X#endif
- X
- X decode(in, out);
- X
- X if (fgets(buf, sizeof buf, in) == NULL || strcmp(buf, "end\n")) {
- X fprintf(stderr, "No end line\n");
- X exit(5);
- X }
- X exit(0);
- X}
- X
- X/*
- X * copy from in to out, decoding as you go along.
- X */
- X
- Xvoid
- Xdecode(in, out)
- XFILE *in;
- XFILE *out;
- X{
- X char buf[80];
- X char *bp;
- X int n;
- X
- X for (;;) {
- X /* for each input line */
- X if (fgets(buf, sizeof buf, in) == NULL) {
- X printf("Short file\n");
- X exit(10);
- X }
- X n = DEC(buf[0]);
- X if (n <= 0)
- X break;
- X
- X bp = &buf[1];
- X while (n > 0) {
- X outdec(bp, out, n);
- X bp += 4;
- X n -= 3;
- X }
- X }
- X}
- X
- X/*
- X * output a group of 3 bytes (4 input characters).
- X * the input chars are pointed to by p, they are to
- X * be output to file f. n is used to tell us not to
- X * output all of them at the end of the file.
- X */
- X
- Xvoid
- Xoutdec(p, f, n)
- Xchar *p;
- XFILE *f;
- X{
- X int c1, c2, c3;
- X
- X c1 = DEC(*p) << 2 | DEC(p[1]) >> 4;
- X c2 = DEC(p[1]) << 4 | DEC(p[2]) >> 2;
- X c3 = DEC(p[2]) << 6 | DEC(p[3]);
- X if (n >= 1)
- X putc(c1, f);
- X if (n >= 2)
- X putc(c2, f);
- X if (n >= 3)
- X putc(c3, f);
- X}
- X
- X
- X/* fr: like read but stdio */
- Xint
- Xfr(fd, buf, cnt)
- XFILE *fd;
- Xchar *buf;
- Xint cnt;
- X{
- X int c, i;
- X
- X for (i=0; i<cnt; i++) {
- X c = getc(fd);
- X if (c == EOF)
- X return(i);
- X buf[i] = c;
- X }
- X return (cnt);
- X}
- X
- X/*
- X * Return the ptr in sp at which the character c appears;
- X * NULL if not found
- X */
- X
- Xchar *
- Xindex(sp, c)
- Xregister char *sp, c;
- X{
- X do {
- X if (*sp == c)
- X return(sp);
- X } while (*sp++);
- X return(NULL);
- X}
- X
- Xvoid
- Xxerror(err)
- Xchar *err;
- X{
- X printf("Can not open file \"%s\"\n", err);
- X}
- X
- END_OF_FILE
- if test 3321 -ne `wc -c <'uucp2/src/unix/uudecode.c'`; then
- echo shar: \"'uucp2/src/unix/uudecode.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/unix/uudecode.c'
- fi
- if test -f 'uucp2/src/uucico/modem.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/uucico/modem.c'\"
- else
- echo shar: Extracting \"'uucp2/src/uucico/modem.c'\" \(3827 characters\)
- sed "s/^X//" >'uucp2/src/uucico/modem.c' <<'END_OF_FILE'
- X
- X/*
- X * MODEM.C
- X *
- X * (C) Copyright 1989-1990 by Matthew Dillon, All Rights Reserved.
- X *
- X * $Header: Beta:src/uucp/src/uucico/RCS/modem.c,v 1.1 90/02/02 11:56:00 dillon Exp Locker: dillon $
- X */
- X
- X#include "includes.h"
- X#include "uucp.h"
- X#include "log.h"
- X
- XPrototype void openline(void);
- XPrototype int get_baud(void);
- XPrototype void modem_init(void);
- XPrototype int dial_nbr(const char *);
- XPrototype void reset_modem(void);
- X
- X/*
- X * NOTE: modem stuff pretty much ignored if we are run from
- X * a getty.
- X */
- X
- X#define MULTIMODEM /* I have a multi-modem */
- X
- Xextern int Getty;
- Xextern int IgnoreCD;
- X
- X
- X
- Xvoid
- Xopenline()
- X{
- X signal(SIGINT,sigint);
- X IgnoreCD |= 4;
- Xstart_again:
- X chkabort();
- X if (instr("CONNECT", 7))
- X goto start_again;
- X
- X
- X#ifdef MULTIMODEM
- X
- X#else
- X set_baud(get_baud());
- X#endif
- X Delay(120); /* sleep 2 seconds */
- X
- X IgnoreCD &= ~4;
- X}
- X
- X#ifndef MULTIMODEM
- X
- Xint
- Xget_baud()
- X{
- X/* We've seen the CONNECT message, now we must see what baud rate
- X we've connected with */
- X/* gather input until \r then see if it's 300, 1200, or 2400 */
- X/* this is for hayes compatibles */
- X
- X int data;
- X char rate[10];
- X int rate_inx = 0;
- X
- X DEBUG(2,"looking for baud rate\n",0);
- X
- X while ( ((data = xgetc(BYTE_TO)) != EOF) && ((char)data != '\r')) {
- X if ((char)data == ' ') continue;
- X rate[rate_inx++] = (char)data;
- X }
- X DEBUG(2, "found baud rate of %s\n", rate);
- X if (strncmp(rate,"1200",4) == 0) return 1200;
- X if (strncmp(rate,"2400",4) == 0) return 2400;
- X if (rate_inx == 0) return 300;
- X return 1200; /* default */
- X}
- X
- X#endif
- X
- Xvoid
- Xmodem_init()
- X{
- X reset_modem();
- X}
- X
- X/*
- X * Simple dialer routine. Needs replacement with a full blown
- X * script driven dialer. Next week maybe :-). FIXME.
- X */
- X
- Xint
- Xdial_nbr(nbr)
- Xconst char *nbr;
- X{
- X char *dial;
- X int i;
- X
- X IgnoreCD |= 4;
- X
- X dial = malloc(strlen(nbr) + 16);
- X
- X dial[0] = 0;
- X if (strncmp(nbr, "AT", 2) != 0 && strncmp(nbr, "at", 2) != 0)
- X strcpy(dial, "ATDT");
- X strcat(dial, nbr);
- X strcat(dial, "\r");
- X
- X DEBUG(2,"dialing %s\n", dial);
- X
- X twrite(dial, strlen(dial));
- X
- X i = instr("CONNECT", 7);
- X
- X if (i == 0) /* for those modems which don't bring CD up */
- X Delay(50); /* immediately */
- X
- X IgnoreCD &= ~4;
- X
- X free(dial);
- X
- X return (i);
- X}
- X
- X/*
- X * RESET_MODEM()
- X *
- X * If run from a Getty we do NOT reset the modem, which would
- X * disconnect an already connected connection.
- X *
- X * Note that the delay between CloseSerial() and OpenSerial() only
- X * serves to give the Getty, if running, time to lock the port and
- X * begin a disconnect sequence.
- X */
- X
- Xvoid
- Xreset_modem()
- X{
- X if (Getty) /* called from a getty */
- X return;
- X DEBUG(4, "Beg-Reset\n", 0);
- X CloseSerial(); /* drop dtr */
- X Delay(50*3); /* delay 3 seconds */
- X DEBUG(4, "End-Reset-1\n", 0);
- X OpenSerial(); /* re-open serial */
- X DEBUG(4, "End-Reset-2\n", 0);
- X}
- X
- X#ifdef NOTDEF
- X
- X if (GettyCmd(DeviceName, DeviceUnit, '0', NULL) == 0)
- X return;
- X
- X /*
- X * Getty doesn't exist, we have to reset the modem ourselves!
- X */
- X
- X IgnoreCD |= 4;
- X
- X#ifdef MULTIMODEM
- X set_baud(19200);
- X
- X if (CheckCarrier()) {
- X Delay(60);
- X twrite("+++", 3);
- X Delay(120);
- X }
- X twrite("ATH0\r", 5);
- X instr("OK\r\n", 4);
- X twrite("ATZ\r", 4);
- X instr("OK\r\n", 4);
- X twrite("ATZ\r", 4);
- X instr("OK\r\n", 4);
- X
- X /*amiga_closeopen();*/
- X sprintf(init, "%s\r", "ATM0S0=2X4$BA0");
- X if (debug > 0)
- X init[3] = '1';
- X twrite(init, strlen(init));
- X instr("OK\r\n",4);
- X#else
- X twrite("+++", 3);
- X Delay(60);
- X twrite("ATH0\r", 5);
- X Delay(120);
- X twrite("ATZ\r", 4);
- X Delay(60);
- X twrite("ATZ\r", 4);
- X Delay(60);
- X sprintf(init, "%s\r", "ATS2");
- X twrite(init, strlen(init));
- X Delay(60);
- X#endif
- X IgnoreCD &= ~4;
- X}
- X
- X#endif
- X
- END_OF_FILE
- if test 3827 -ne `wc -c <'uucp2/src/uucico/modem.c'`; then
- echo shar: \"'uucp2/src/uucico/modem.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/uucico/modem.c'
- fi
- if test -f 'uucp2/src/uucico/uucp.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/uucico/uucp.c'\"
- else
- echo shar: Extracting \"'uucp2/src/uucico/uucp.c'\" \(4098 characters\)
- sed "s/^X//" >'uucp2/src/uucico/uucp.c' <<'END_OF_FILE'
- X
- X/*
- X * UUCP.c written by William Loftus
- X * Copyright 1988 by William Loftus. All rights reserved.
- X *
- X * $Header: Beta:src/uucp/src/uucico/RCS/uucp.c,v 1.1 90/02/02 11:56:13 dillon Exp Locker: dillon $
- X *
- X */
- X
- X#include <stdio.h>
- X#include <stdlib.h>
- X#include <string.h>
- X#include "version.h"
- X
- XIDENT(".01");
- X
- Xchar to_buf[128];
- Xchar from_buf[128];
- Xchar path[128];
- Xchar user[8];
- X
- Xchar command_file[128];
- Xint seq;
- X
- Xvoid BuildReceiveFile();
- Xvoid BuildSendFile();
- Xvoid read_ctl();
- Xchar *expand_file();
- Xchar *strchr();
- Xchar *getcwd();
- X
- X#define TRUE 1
- X#define FALSE 0
- X
- XCXBRK()
- X{
- X return(0);
- X}
- X
- Xvoid
- Xmain(argc,argv)
- Xint argc;
- Xchar **argv;
- X{
- X int to_bang, from_bang;
- X
- X if (argc != 3) {
- X printf("Usage: UUCP from_file to_file\n");
- X exit(1);
- X } else {
- X strcat(from_buf, argv[1]);
- X strcat(to_buf, argv[2]);
- X }
- X
- X getcwd(path,128);
- X
- X if (chdir(GetConfigDir(UUSPOOL))) {
- X printf("Couldn't change current working directory to %s\n", GetConfigDir(UUSPOOL));
- X exit(1);
- X }
- X
- X read_ctl();
- X
- X seq = GetSequence(2);
- X if (seq < 0) {
- X chdir(path);
- X exit(1);
- X }
- X
- X from_bang = (int)strchr(from_buf,'!');
- X to_bang = (int)strchr(to_buf,'!');
- X
- X if (from_bang && to_bang) {
- X printf("Can not specify a remote system in both arguments.\n");
- X chdir(path);
- X exit(1);
- X }
- X
- X if (from_bang) {
- X BuildReceiveFile();
- X }
- X
- X if (to_bang) {
- X BuildSendFile();
- X }
- X
- X chdir(path);
- X exit(0);
- X}
- X
- Xvoid
- XBuildSendFile()
- X{
- X FILE *fp;
- X char system_name[32];
- X int bang;
- X
- X strcpy(from_buf,expand_file(from_buf));
- X
- X bang = (int)strchr(to_buf,'!');
- X bang = bang - (int)to_buf;
- X
- X strncpy(system_name,to_buf,bang);
- X
- X system_name[bang] = '\0';
- X
- X if (!is_in_L_sys_file(system_name)) {
- X printf("System \"%s\" not in L.sys file.\n", system_name);
- X chdir(path);
- X exit(1);
- X }
- X
- X system_name[7] = '\0';
- X
- X sprintf(command_file,"C.%sA%04d", system_name, seq++);
- X
- X LockFile(command_file);
- X
- X fp = fopen(command_file,"w");
- X
- X if (fp) {
- X /* srcnam desnam who flags temp mode who */
- X fprintf(fp,"S %s %s %s %s %s %s %s\n",
- X from_buf,
- X to_buf + bang + 1,
- X user,
- X "-c",
- X from_buf,
- X "0666",
- X user
- X );
- X fclose(fp);
- X } else {
- X UnLockFile(command_file);
- X perror(command_file);
- X chdir(path);
- X exit(1);
- X }
- X UnLockFile(command_file);
- X printf("Command queue for transfer to %s.\n", system_name);
- X}
- X
- Xvoid
- XBuildReceiveFile()
- X{
- X FILE *fp;
- X char system_name[32];
- X int bang;
- X
- X strcpy(to_buf,expand_file(to_buf));
- X
- X bang = (int)strchr(from_buf,'!');
- X bang = bang - (int)from_buf;
- X
- X strncpy(system_name,from_buf,bang);
- X
- X system_name[bang] = '\0';
- X
- X if (!is_in_L_sys_file(system_name)) {
- X printf("System \"%s\" not in L.sys file.\n", system_name);
- X chdir(path);
- X exit(1);
- X }
- X
- X system_name[7] = '\0';
- X
- X sprintf(command_file,"C.%sA%04d", system_name, seq++);
- X
- X LockFile(command_file);
- X
- X fp = fopen(command_file,"w");
- X if (fp) {
- X /* srcnam desnam who flags */
- X fprintf(fp,"R %s %s %s %s\n",
- X from_buf + bang + 1,
- X to_buf,
- X user,
- X "-c"
- X );
- X fclose(fp);
- X } else {
- X UnLockFile(command_file);
- X perror(command_file);
- X chdir(path);
- X exit(1);
- X }
- X UnLockFile(command_file);
- X printf("Command queue for transfer from %s.\n", system_name);
- X}
- X
- Xstatic char name[128];
- X
- Xchar *
- Xexpand_file(file_name)
- Xchar *file_name;
- X{
- X char *colon;
- X
- X colon = strchr(file_name,':');
- X if ((colon != (char*)NULL) && (colon != file_name)) {
- X return(file_name);
- X } else {
- X if (path[strlen(path)-1] != ':') {
- X sprintf(name,"%s/%s",path,file_name);
- X return name;
- X } else {
- X sprintf(name,"%s%s",path,file_name);
- X return name;
- X }
- X }
- X}
- X
- X#define CTL_DELIM " \t\r\n"
- X
- X/*
- X * Read the control file and grab a few parameters.
- X */
- X
- Xvoid
- Xread_ctl()
- X{
- X FILE *fd;
- X static char buf[128];
- X
- X if (! (fd = fopen(MakeConfigPath(UULIB, "Config"), "r"))) {
- X printf("Can't Find config file.\n");
- X chdir(path);
- X exit(3);
- X }
- X
- X while (NULL != fgets(buf, sizeof buf, fd)) {
- X if (strncmp(buf, "UserName", 8) == 0)
- X strcpy(user, strtok(&buf[9], CTL_DELIM) ) ;
- X }
- X fclose(fd);
- X}
- X
- X
- END_OF_FILE
- if test 4098 -ne `wc -c <'uucp2/src/uucico/uucp.c'`; then
- echo shar: \"'uucp2/src/uucico/uucp.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/uucico/uucp.c'
- fi
- if test -f 'uucp2/src/uucico/uux.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uucp2/src/uucico/uux.c'\"
- else
- echo shar: Extracting \"'uucp2/src/uucico/uux.c'\" \(3324 characters\)
- sed "s/^X//" >'uucp2/src/uucico/uux.c' <<'END_OF_FILE'
- X
- X/*
- X * UUX.C
- X *
- X * $Header: Beta:src/uucp/src/uucico/RCS/uux.c,v 1.1 90/02/02 11:56:20 dillon Exp Locker: dillon $
- X *
- X * Copyright 1988 by William Loftus. All rights reserved.
- X *
- X * Example: 1> uux mail-message "burdvax!rmail wpl"
- X */
- X
- X#include <stdio.h>
- X#include <stdlib.h>
- X#include <string.h>
- X#include "version.h"
- X
- XIDENT(".02");
- X
- Xchar user[128];
- Xchar file_name[128];
- Xchar command[128];
- X
- Xchar exec_file[128];
- Xchar x_exec_file[128];
- Xchar command_file[128];
- Xchar data_file[128];
- Xint seq;
- X
- Xchar path[128];
- X
- Xvoid GetTo();
- Xvoid GetSubject();
- X
- X#define TRUE 1
- X#define FALSE 0
- X
- Xint
- Xbrk()
- X{
- X return(0);
- X}
- X
- Xvoid
- Xmain(argc, argv)
- Xint argc;
- Xchar **argv;
- X{
- X int error;
- X char *up = FindConfig(USERNAME);
- X
- X onbreak(brk);
- X if (up == NULL) {
- X printf("couldn't find domain entry for %s\n", USERNAME);
- X exit(1);
- X }
- X strcpy(user, up);
- X
- X getcwd(path,128);
- X chdir(GetConfigDir(UUSPOOL));
- X if (argc == 3) {
- X strcpy(file_name, argv[1]);
- X strcpy(command, argv[2]);
- X } else {
- X printf("Usage: uux file-name command\n");
- X printf("Example: 1> uux mail-message \"burdvax!rmail wpl\"\n");
- X chdir(path);
- X exit(1);
- X }
- X seq = GetSequence(4);
- X if (seq >= 0)
- X error = Queue();
- X UnLockFile(exec_file);
- X UnLockFile(x_exec_file);
- X UnLockFile(command_file);
- X UnLockFile(data_file);
- X chdir(path);
- X if (seq < 0 || error < 0)
- X exit(1);
- X}
- X
- XQueue()
- X{
- X FILE *fp;
- X char system_name[32];
- X int bang;
- X int error;
- X
- X bang = (int)strchr(command,'!');
- X bang = bang - (int)command;
- X
- X strncpy(system_name,command,bang);
- X
- X system_name[bang] = '\0';
- X
- X if (!is_in_L_sys_file(system_name)) {
- X printf ("System \"%s\" not in L.sys file.\n", system_name);
- X return(-1);
- X }
- X
- X system_name[7] = '\0';
- X
- X sprintf(exec_file,"D.%sX%04d", system_name, seq++);
- X sprintf(x_exec_file,"X.%sX%04d", system_name, seq++);
- X sprintf(command_file,"C.%sA%04d", system_name, seq++);
- X sprintf(data_file,"D.%sB%04d", system_name, seq);
- X
- X LockFile(exec_file);
- X LockFile(x_exec_file);
- X LockFile(command_file);
- X LockFile(data_file);
- X
- X fp = fopen(exec_file,"w");
- X if (fp) {
- X fprintf(fp,"U %s\n", user);
- X fprintf(fp,"F %s\n", data_file);
- X fprintf(fp,"I %s\n", data_file);
- X fprintf(fp,"C %s\n", (char *)command + bang + 1);
- X fclose(fp);
- X } else {
- X perror(exec_file);
- X return(-1);
- X }
- X
- X fp = fopen(command_file,"w");
- X if (fp) {
- X fprintf(fp,"S %s %s %s - %s 0666\n",
- X data_file,
- X data_file,
- X user,
- X data_file
- X );
- X fprintf(fp,"S %s %s %s - %s 0666\n",
- X exec_file,
- X x_exec_file,
- X user,
- X exec_file
- X );
- X fclose(fp);
- X } else {
- X perror(command_file);
- X return(-1);
- X }
- X chdir(path);
- X error = Copy(file_name, data_file);
- X chdir(GetConfigDir(UUSPOOL));
- X return(error);
- X}
- X
- X/*
- X * Read the control file and grab a few parameters.
- X */
- X
- XCopy(from, to)
- Xchar *from;
- Xchar *to;
- X{
- X FILE *fd;
- X FILE *td;
- X int c;
- X static char to_buf[128];
- X
- X fd = fopen(from, "r");
- X if (!fd) {
- X printf("Could not open %s.\n", from);
- X perror(from);
- X return(-1);
- X }
- X
- X strcpy(to_buf, MakeConfigPath(UUSPOOL, to));
- X
- X td = fopen(to_buf, "w");
- X if (!td) {
- X printf("Could not open %s.\n", to_buf);
- X perror(to);
- X return(-1);
- X }
- X while ((c = fgetc(fd)) != EOF) {
- X fputc((char)c, td);
- X }
- X fclose(fd);
- X fclose(td);
- X return(1);
- X}
- X
- X
- END_OF_FILE
- if test 3324 -ne `wc -c <'uucp2/src/uucico/uux.c'`; then
- echo shar: \"'uucp2/src/uucico/uux.c'\" unpacked with wrong size!
- fi
- # end of 'uucp2/src/uucico/uux.c'
- fi
- echo shar: End of archive 4 \(of 12\).
- cp /dev/null ark4isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 12 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
- Mail comments to the moderator at <amiga-request@cs.odu.edu>.
- Post requests for sources, and general discussion to comp.sys.amiga.
-